package com.mnyc.service;

import com.mnyc.http.FeignServerrClient;
import com.mnyc.model.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class FeignServerService {
    @Autowired
    FeignServerrClient feignServerrClient;
    String flag = "FeignClient";

    public void get() {
        try {
            String result = "";
            result = feignServerrClient.getMethod(flag);
            log.info("Feign ========= " + result);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    public void post() {
        try {
            String result = "";
            User user = new User();
            user.setName("name");
            user.setAge(100);
            result = feignServerrClient.postMethod(flag, user);
            log.info("Feign ========= " + result);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    public void put() {
        try {
            String result = "";
            User user = new User();
            user.setName("name");
            user.setAge(100);
            result = feignServerrClient.putMethod(flag, user);
            log.info("Feign ========= " + result);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    public void delete() {
        try {
            String result = "";
            User user = new User();
            user.setName("name");
            user.setAge(100);
            result = feignServerrClient.deleteMethod(flag);
            log.info("Feign ========= " + result);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    public void path() {
        try {
            String result = "";
            User user = new User();
            user.setName("name");
            user.setAge(100);
            result = feignServerrClient.pathMethod(flag,user);
            log.info("Feign ========= " + result);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}
